<template>
  <div ref="main" style="width: 1200px;height:800px;margin: 50px auto;" />
</template>

<script>
import storage from "store"
export default {
  name: 'Dashboard',
  data() {
    return {
    }
  },
  created() {},
  mounted() {
    this.initEcharts(storage.get("3"))
  },
  methods: {
    initEcharts(datas) {
      var myChart = this.$echarts.init(this.$refs.main)
      var option = {
        title: {
          text: '消费者最喜爱商品分析',
          subtext: '按商品类型',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: '占所有商品的',
            type: 'pie',
            radius: '50%',
            data: datas,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
      option && myChart.setOption(option)
    }
  }
}
</script>
